package ms.maplestory.boot.client.character.quest.progress;

import lombok.Getter;
import lombok.Setter;
import ms.maplestory.boot.client.character.Char;
import ms.maplestory.boot.loaders.DatSerializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

@Getter
@Setter
@Entity
@DiscriminatorValue("money")
public class QuestProgressMoneyRequirement extends QuestProgressRequirement {

    @Column(name = "requiredCount")
    private int money;

    public QuestProgressMoneyRequirement() {
    }

    public QuestProgressMoneyRequirement(int money) {
        this.money = money;
    }

    @Override
    public void write(DataOutputStream dos) throws IOException {
        dos.writeInt(getMoney());
    }

    @Override
    public DatSerializable load(DataInputStream dis) throws IOException {
        return new QuestProgressMoneyRequirement(dis.readInt());
    }

    @Override
    public boolean isComplete(Char chr) {
        return false;
    }

    @Override
    public QuestProgressRequirement deepCopy() {
        QuestProgressMoneyRequirement questProgressMoneyRequirement = new QuestProgressMoneyRequirement();
        questProgressMoneyRequirement.setMoney(getMoney());
        questProgressMoneyRequirement.setOrder(getOrder());
        return questProgressMoneyRequirement;
    }
}
